<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=0.5" />
    <title>Document</title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      .box {
        width: 100%;
        height: 100px;
        background-color: red;
      }
    </style>
  </head>
  <body>
    <h1 id="vp"></h1>
    <h1 id="vp1"></h1>
    <div class="box"></div>
    <img src="./imgs/1.jpg" alt="" />
    <img src="./imgs/2.jpg" alt="" />
    <img src="./imgs/3.jpg" alt="" />
    <img src="./imgs/4.jpg" alt="" />
    <script>
      const vp = document.getElementById('vp')
      const vp1 = document.getElementById('vp1')
      setInterval(() => {
        vp.innerText = '布局视口: ' + document.documentElement.clientWidth
        vp1.innerText = '视觉视口:' + window.innerWidth
      }, 20)
    </script>
  </body>
</html>
